<?php

use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class OrganizationUserModel extends Model
{
    use HasFactory;

    protected $table = 'organization_users';

    protected $fillable = [];

    /**
     * 将查询作用域限制为仅包含给定类型的用户。
     */
    public function scopeOrg(Builder $query, int $orgId): void
    {
        $query->where('organization_id', $orgId);
    }

    public function roleExits(): BelongsTo
    {
        return $this->belongsTo(UserHasRoleModel::class, 'user_id', 'user_id');
    }

}
